package tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.Vector;

import objects.Frm;
import objects.Message;
import objects.Trd;
import objects.User;

import org.junit.Test;

import Domain.stompProtocol.ForumFrame;

public class ForumFrameTest
{


	@Test
	public void testForumFrame()
	{
		
		ForumFrame s=new ForumFrame();
		assertNotNull(s);
	}
	
	ForumFrame s=new ForumFrame();
	
	@Test
	public void testForumFrameFrm()
	{
		Frm f=new Frm();
		f.setForumName("Asaf");
		s=new ForumFrame(f);
		Frm ff=(Frm)s.getData();
		int t=s.getType();
		assertEquals(ff, f);
		assertEquals(t, ForumFrame.TYPEFORUM);
	}

	@Test
	public void testForumFrameTrd()
	{
		Trd t=new Trd();
		t.setThreadName("Asaf");
		s=new ForumFrame(t);
		Trd tt=(Trd)s.getData();
		int type=s.getType();
		assertEquals(tt, t);
		assertEquals(type, ForumFrame.TYPETHREAD);
	}

	@Test
	public void testForumFrameMessage()
	{
		User u=new User(); 
		Message m=new Message();//u,"Asaf");
		s=new ForumFrame(m);
		Message mm=(Message)s.getData();
		int type=s.getType();
		assertEquals(mm, m);
		assertEquals(type, ForumFrame.TYPEMESSAGE);
	}

	@Test
	public void testSetVectorTrd()
	{
		Vector<Trd> t=new Vector<Trd>();
		t.add(new Trd());
		s.setVectorTrd(t);
		int type=s.getType();
		Vector<Trd> tt=(Vector<Trd>)s.getData();
		assertEquals(tt, t);
		assertEquals(type, ForumFrame.VECTORTRD);
		
	}

	@Test
	public void testSetVectorFrm()
	{
		Vector<Frm> f=new Vector<Frm>();
		f.add(new Frm());
		s.setVectorFrm(f);
		int type=s.getType();
		Vector<Frm> ff=(Vector<Frm>)s.getData();
		assertEquals(ff, f);
		assertEquals(type, ForumFrame.VECTORFRM);
	}

	@Test
	public void testSetVectorMsg()
	{
		User u=new User(); 
		Message msg=new Message();
		Vector<Message> m=new Vector<Message>();
		m.add(msg);
		s.setVectorMsg(m);
		int type=s.getType();
		Vector<Message> mm=(Vector<Message>)s.getData();
		assertEquals(mm, m);
		assertEquals(type, ForumFrame.VECTORMSG);
	}

	@Test
	public void testSetErr()
	{
		s=new ForumFrame();
		assertNull(s.getData());
		assertEquals(s.getType(), ForumFrame.UNINTIALIZE);
		
		s.setErr(ForumFrame.ERRUserNotFound);
		assertNull(s.getData());
		assertEquals(s.getType(), ForumFrame.ERRUserNotFound);
	}



}
